﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;

namespace HZU.ZP.Domain.Model
{
    public class AjaxResult
    {
        /// <summary>
        /// 返回码（1：成功，0：失败）
        /// </summary>
        [Description("返回码（1：成功，0：失败）")]
        public int ReturnCode { get; set; }

        /// <summary>
        /// 返回信息
        /// </summary>
        public string Message { get; set; }

        /// <summary>
        /// 成功可能时返回的数据
        /// </summary>
        public object Root { get; set; }


        public int Total { get; set; }

        public static AjaxResult ReturnMessage()
        {
            return new AjaxResult()
            {
                ReturnCode = 11,
            };
        }
        public static AjaxResult ReturnMessage(int returncode, string message)
        {
            return new AjaxResult()
            {
                ReturnCode = returncode,
                Message = message,
                Root = "",
                Total = 0,
            };
        }
        public static AjaxResult ReturnMessage(object root)
        {
            return new AjaxResult()
            {
                ReturnCode = 11,
                Message = "通用成功",
                Root = root ?? ""
            };
        }
        public static AjaxResult ReturnMessage(int returncode, string message, object root)
        {
            return new AjaxResult()
            {
                Root = root ?? "",
                ReturnCode = returncode,
                Message = message,
                Total = 0,
            };
        }
        public static AjaxResult ReturnMessage(int returncode, string message, object root, int total)
        {
            return new AjaxResult()
            {
                Root = root ?? "",
                ReturnCode = returncode,
                Message = message,
                Total = total,
            };
        }              
    }
}
